#include "md_dtv.h"
#include "ui_md_dtv.h"

Md_dtv::Md_dtv(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Md_dtv)
{
    ui->setupUi(this);
}

Md_dtv::Md_dtv(TCL_MSTAR_DTV_TV *mstar,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Md_dtv)
{
    ui->setupUi(this);
    Q_CHECK_PTR(mstar);
    solution=1;
    mstar->Get_Data(&ch_data);

    ms_dtv=mstar;
    My_Init();

}
Md_dtv::Md_dtv(TCL_MTK_DTV_TV *mtk, QWidget *parent):
    QWidget(parent),
    ui(new Ui::Md_dtv)
{
    ui->setupUi(this);
    Q_CHECK_PTR(mtk);
    solution=0;
    mtk->Get_Data(&ch_data);
    mt_dtv=mtk;
    My_Init();

}

Md_dtv::~Md_dtv()
{
    delete ui;
}

void Md_dtv::My_Init()
{
    ui->label->setText("Channel Number:");
    ui->Item1->setText(ch_data.at(0));
    ui->label->setText("Channel Name");
    ui->Item2->setText(ch_data.at(1));
    ui->label_3->setText("Channel Class");
    ui->Item3->setText(ch_data.at(2));
    ui->Item3->setEnabled(false);
    ui->label_4->setText("Favorite Flag:");
    ui->Item4->setText(ch_data.at(3));
    ui->label_5->setText("Flag Flag:");
    ui->Item5->setText(ch_data.at(4));
    connect(ui->pB_Confirm,SIGNAL(clicked()),this,SLOT(Confirm()));
}

bool Md_dtv::is_close()
{


}


void Md_dtv::Confirm()
{
    QString tmp;
    ch_data.clear();
    ch_data.append(ui->Item1->text());
    ch_data.append(ui->Item2->text());
    if(ui->Item3->text().compare("DTV-B")==0)
        tmp.setNum(66);
    else if(ui->Item3->text().compare("DTV-C")==0)
        tmp.setNum(67);
    else
        tmp.setNum(84);

    ch_data.append(tmp);
    ch_data.append(ui->Item4->text());
    ch_data.append(ui->Item5->text());
    if(1==solution)
    {
        ms_dtv->Set_Data(ch_data);
        emit Mstar_Close(*ms_dtv);

    }
    else if(0==solution)
    {
        mt_dtv->Set_Data(ch_data);
        emit Mtk_Close(*mt_dtv);
    }

    this->close();
}


